namespace DotNetNuke.Security.Permissions
{
    using System;
    using System.Xml.Serialization;

    public class ModulePermissionInfo : PermissionInfo
    {
        private bool _AllowAccess;
        private int _moduleID;
        private int _modulePermissionID;
        private string _permissionKey;
        private int _roleID;
        private string _RoleName;

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Compares if two ModulePermissionInfo objects are equivalent/equal
        /// </summary>
        /// <param name="obj">a ModulePermissionObject</param>
        /// <returns>true if the permissions being passed represents the same permission
        /// in the current object
        /// </returns>
        /// <remarks>
        /// This function is needed to prevent adding duplicates to the ModulePermissionCollection.
        /// ModulePermissionCollection.Contains will use this method to check if a given permission
        /// is already included in the collection.
        /// </remarks>
        /// <history>
        /// [Vicen鏬	09/01/2005	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override bool Equals(object obj)
        {
            if ((obj == null) | (this.GetType() != obj.GetType()))
            {
                return false;
            }
            ModulePermissionInfo perm = (ModulePermissionInfo) obj;
            return ((((this.AllowAccess == perm.AllowAccess) & (this.ModuleID == perm.ModuleID)) & (this.RoleID == perm.RoleID)) & (this.PermissionID == perm.PermissionID));
        }

        [XmlElement("allowaccess")]
        public bool AllowAccess
        {
            get
            {
                return this._AllowAccess;
            }
            set
            {
                this._AllowAccess = value;
            }
        }

        [XmlIgnore]
        public int ModuleID
        {
            get
            {
                return this._moduleID;
            }
            set
            {
                this._moduleID = value;
            }
        }

        [XmlIgnore]
        public int ModulePermissionID
        {
            get
            {
                return this._modulePermissionID;
            }
            set
            {
                this._modulePermissionID = value;
            }
        }

        [XmlIgnore]
        public int RoleID
        {
            get
            {
                return this._roleID;
            }
            set
            {
                this._roleID = value;
            }
        }

        [XmlElement("rolename")]
        public string RoleName
        {
            get
            {
                return this._RoleName;
            }
            set
            {
                this._RoleName = value;
            }
        }
    }
}

